<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      #box {
        border: solid;
        width: 400px;
        padding: 20px;
      }
    </style>
  </head>
  <body>
    <div id="box">
      <button id="btn">X</button>
      text...
    </div>
    <script>
      const btn = document.getElementById("btn");
      const box = document.getElementById("box");

      btn.onclick = function(){
        box.style.display = 'none'
      }
    </script>
  </body>
</html>
